var util = require('../../../utils/util.js');
import Toast from '../../../dist/toast/toast';
var app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        email: '',
        content: ''
    },
    emailImput(e) {
        this.setData({
            email: e.detail
        })
    },
    contentImput(e) {
        this.setData({
            content: e.detail
        })
    },
    submit() {
        const contact = this.data.email
        const content = this.data.content
        if (!contact || !content) {
            Toast('邮箱或内容为空');
            return;
        } else {
            var dataUrl = app.globalData.apiBase +
                "/blog/addLeaveMessage";
            util.ajax(dataUrl, "post", this.data, this.processData);
        }
    },

    processData: function () {
      wx.showToast({
        title: '你的留言已收到！谢谢',
      })
      wx.hideNavigationBarLoading();
      wx.stopPullDownRefresh();
    },

})
